go to previous page   go to home page   go to next page

Answer:

Output redirection.

C:\temp>java MultiEcho < input.txt > output.txt

Redirecting both Input and Output

Input and output redirection can be used simultaneously. Here is an example run of the program:

C:\temp>java MultiEcho < input.txt > output.txt

C:\temp>type output.txt
Enter line1:
You typed: This is line one,
Enter line2:
You typed: this is line two,
Enter line3:
You typed: this is line three,
Enter line4:
You typed: this is line four,
Enter line5:
You typed: and this is the last line.

The order on the command line does not matter:

C:\temp>java MultiEcho > output.txt < input.txt

You can have only one input file redirected to a program and one output file redirected from a program.


QUESTION 7:

(Thought Question: ) Can you use redirection to send output to two disk files at the same time?